﻿#define imageOrc

using System;
using System.Collections.Generic;
using System.IO;

namespace Script
{
    /// <summary>
    /// 图片查找形成excel格式并复制出来
    /// https://console.bce.baidu.com/ai/#/ai/ocr/app/list
    /// </summary>
    public class ImageFindAccurateOrc : ImageFindOrc
    {
        public new static void Main()
        {
            new ImageFindAccurateOrc();
            Console.WriteLine("已处理完毕，任意键退出！请查看生成的csv文件。");
            Console.ReadKey();
        }

        public override string GetResult(byte[] imageOrc)
        {
            var options = new Dictionary<string, object>
            {
                {"language_type", "CHN_ENG"},
                {"detect_direction", "true"},
                {"detect_language", "true"},
                {"probability", "true"}
            };
            // 带参数调用通用文字识别, 图片参数为本地图片
            var result = client.AccurateBasic(imageOrc, options).ToString();
            return result;
        }

#if imageOrc
        /// <summary>
        /// 通用文字识别（高精度版）
        /// </summary>
        public void AccurateBasicDemo()
        {
            var image = File.ReadAllBytes("图片文件路径");
            // 调用通用文字识别, 图片参数为本地图片，可能会抛出网络等异常，请使用try/catch捕获
            var result = client.GeneralBasic(image);
            Console.WriteLine(result);
            // 如果有可选参数
            var options = new Dictionary<string, object>
            {
                {"language_type", "CHN_ENG"},
                {"detect_direction", "true"},
                {"detect_language", "true"},
                {"probability", "true"}
            };
            // 带参数调用通用文字识别, 图片参数为本地图片
            result = client.AccurateBasic(image, options);
            Console.WriteLine(result);
        }
#endif
    }
}